home *** CD-ROM | disk | FTP | other *** search
- /*-------------------------------------------------------------------
-
- AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
- Mail Service Access Module
-
- written by Steve Falkenburg-- MacDTS
- ©1991-1993 Apple Computer, Inc.
-
- --------------
- change history
- --------------
-
- SJF 02/19/93 update for beta build b1
- SJF 10/29/92 update to a11 a11
- SJF 06/08/92 update to a8 a8
- SJF 02/15/92 first working version a4.5
- SJF 10/16/91 initial coding a3
-
- ---------------------------------------------------------------------*/
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __EPPC_
- #include <EPPC.h>
- #endif
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifndef __OCE__
- #include <OCE.h>
- #endif
-
- #ifndef __OCEMAIL__
- #include <OCEMail.h>
- #endif
-
- #ifndef __OCEERRORS__
- #include <OCEErrors.h>
- #endif
-
- #include "const.h"
- #include "gwerrors.h"
- #include "globals.h"
- #include "mytypes.h"
- #include "utils.h"
- #include "gatewayevents.h"
- #include "gatewayget.h"
- #include "gatewayput.h"
- #include "myevents.h"
-
-
- // HandleEvent
- //
- // called when WaitNextEvent gets an event that we need to process. we're only a
- // background only application, so we just process high level events
- //
- // input: ev event record returned from WaitNextEvent
- //
- OSErr HandleEvent(EventRecord *ev,Boolean inMainEventLoop)
- {
- OSErr err = noErr;
-
- // we only handle high level events...
-
- switch (ev->what) {
- case kHighLevelEvent:
- err = DoHighLevelEvent(ev,inMainEventLoop);
- break;
- }
-
- return err;
- }
-
-
- // DoHighLevelEvent
- //
- // called to process high level events. we accept both core appleevents and AOCE events
- //
- // input: ev event record returned from WaitNextEvent
- //
- OSErr DoHighLevelEvent(EventRecord *ev,Boolean inMainEventLoop)
- {
- OSErr err;
- TargetID sender;
- OSType messageID;
- short slotID;
- unsigned long refCon;
- unsigned long msgLen;
- Ptr buff;
- MailEPPCMsg *mailEPPC;
-
- msgLen = 0;
- buff = nil;
-
- err = AcceptHighLevelEvent(&sender,&refCon,buff,&msgLen);
- if (err==bufferIsSmall) {
- buff = NewPtrChk(msgLen);
- if (MemError()!=noErr)
- return MemError();
- err = AcceptHighLevelEvent(&sender,&refCon,buff,&msgLen);
- }
-
- if (err!=noErr)
- return err;
-
- messageID = * (unsigned long *) &ev->where;
-
- switch (ev->message) {
- case kMailAppleMailCreator:
- mailEPPC = (MailEPPCMsg *) buff;
- slotID = ev->modifiers;
- err = DoGatewayEvent(messageID,mailEPPC,slotID,inMainEventLoop);
- break;
- case kCoreEventClass:
- err = HandleCoreEvents(messageID,buff,msgLen);
- default:
- break;
- }
-
- DisposPtrChk(buff);
- return err;
- }
-
-
- // HandleCoreEvents
- //
- // handles core appleevents. we handle these directly rather than using the appleevent
- // dispatching mechanism. note that we're really only handling quit.
- //
- // input: messageID type of event
- // buff high level event message buffer
- // msgLen high level event message length
- //
- OSErr HandleCoreEvents(long messageID,Ptr buff,unsigned long msgLen)
- {
- #pragma unused (buff,msgLen)
- OSErr err = noErr;
-
- switch (messageID) {
- case kAEOpenApplication:
- break;
- case kAEOpenDocuments:
- break;
- case kAEPrintDocuments:
- break;
- case kAEQuitApplication:
- err = ShutDownServer();
- break;
- }
- return err;
- }